package com.java.shop.util;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations;

/**
 * redis工具类
 */
public class RedisUtil {

    @Autowired
    private static StringRedisTemplate stringRedisTemplate;

    public static void setString(String key,String value,Integer  outTime){
        // 获取字符串操作对象
        ValueOperations<String, String> stringOperations = stringRedisTemplate.opsForValue();

        stringOperations.set(key,value,outTime);

    }

    public static void main(String[] args) {
        setString("test_1","1111",-1);
    }
}
